package crew.gwt.client.widgets;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DecoratedPopupPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

import crew.gwt.client.widgets.handler.DialogHandler;

public class FormPopupPanel extends DecoratedPopupPanel implements ClickHandler {

	private VerticalPanel vPanel = new VerticalPanel();
	private Button btOK = new Button("Fermer");
	
	private final DialogHandler handler;
	
	public FormPopupPanel(Widget content,DialogHandler handler) {
		super(false, true);
		this.handler = handler;
		setGlassEnabled(true);
		setAnimationEnabled(true);
		btOK.addClickHandler(this);

		vPanel.add(new HTML("<br /> "));
		vPanel.add(content);
		vPanel.add(new HTML("<br /> <hr /> "));
		vPanel.add(btOK);
		
		super.add(vPanel);

		center();
	}

	@Override
	public void onClick(ClickEvent event) {
		hide();
		if ( handler != null && event.getSource().equals(btOK)) {
			handler.onConfirmClick();
		}
	}
	
	@Override
	public void add(Widget w) {
		vPanel.add(w);
	}

	public Button getBtOK() {
		return btOK;
	}
}
